﻿package mortal.game.view.common.tooltip.tooltips
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.common.text.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.tooltip.tooltips.base.*;
    import mortal.game.view.skill.*;

    public class ToolTipGuildSkill extends ToolTipScaleBg
    {
        private var _skill:TSkill;
        private var _txtType:GTextFiled;
        private var _txtName:GTextFiled;
        private var _cur:AutoLayoutTextContainer;
        private var _line1:ScaleBitmap;
        private var _txtMax:GTextFiled;
        private var _next:AutoLayoutTextContainer;

        public function ToolTipGuildSkill()
        {
            this.initUI();
            return;
        }// end function

        override public function get width() : Number
        {
            return 235;
        }// end function

        override public function get height() : Number
        {
            return this._next.y + this._next.height + paddingBottom + paddingTop;
        }// end function

        private function initUI() : void
        {
            setBg(ImagesConst.ToolTipBg);
            this.paddingLeft = 8;
            this.paddingTop = 8;
            this.paddingBottom = 8;
            this.paddingRight = 8;
            var _loc_1:* = GlobalStyle.textFormatPutong;
            _loc_1.size = 14;
            _loc_1.color = 16777215;
            _loc_1.bold = true;
            this._txtType = UIFactory.gTextField("", 0, 0, 120, 22, contentContainer2D, _loc_1);
            _loc_1 = GlobalStyle.textFormatPutong;
            _loc_1.size = 14;
            _loc_1.color = 65280;
            _loc_1.bold = true;
            this._txtName = UIFactory.gTextField("", 85, 0, 120, 22, contentContainer2D, _loc_1);
            this._cur = new AutoLayoutTextContainer();
            this._cur.y = 30;
            this._cur.addNewText(120, "", 12, GlobalStyle.colorAnjinUint);
            this._cur.addNewText(120, "", 12, GlobalStyle.colorLanUint);
            this._cur.verticalGap = -6;
            contentContainer2D.addChild(this._cur);
            this._line1 = UIFactory.bg(0, 65, 232, 2, contentContainer2D, ImagesConst.SplitLine);
            this._txtMax = UIFactory.gTextField("", 0, 70, 200, 20, contentContainer2D);
            this._txtMax.textColor = GlobalStyle.colorHongUint;
            this._next = new AutoLayoutTextContainer();
            this._next.y = 70;
            this._next.addNewText(120, "", 12, GlobalStyle.colorHongUint);
            this._next.addNewText(120, "", 12, GlobalStyle.colorHuiUint);
            this._next.addNewText(120, "", 12, GlobalStyle.colorHuiUint);
            this._next.verticalGap = -6;
            contentContainer2D.addChild(this._next);
            return;
        }// end function

        override public function set data(param1) : void
        {
            var _loc_3:TSkill = null;
            var _loc_4:String = null;
            var _loc_5:int = 0;
            super.data = param1;
            var _loc_2:* = (param1 as SkillInfo).learned;
            this._skill = (param1 as SkillInfo).tSkill;
            this._txtType.text = Language.getString(20798);
            this._txtName.text = this._skill.name;
            if (_loc_2)
            {
                contentContainer2D.addChild(this._cur);
                contentContainer2D.addChild(this._line1);
                this._cur.setText(0, Language.getStringByParam(20236, this._skill.skillLevel));
                this._cur.setText(1, SkillUtil.alySkillDesc(this._skill));
                _loc_3 = SkillConfig.instance.getSkillByLevel(this._skill.series, (this._skill.skillLevel + 1));
                if (_loc_3 == null)
                {
                    DisplayUtil.removeMe(this._next);
                    if (this._txtMax.parent == null)
                    {
                        contentContainer2D.addChild(this._txtMax);
                    }
                    this._txtMax.text = Language.getString(20107);
                }
                else
                {
                    if (this._next.parent == null)
                    {
                        contentContainer2D.addChild(this._next);
                    }
                    DisplayUtil.removeMe(this._txtMax);
                    _loc_4 = GuildUtil.getGuildSkillConfigAttribute(_loc_3.skillId);
                    _loc_5 = GuildSchoolConfig.instance.getLevelById(_loc_4, _loc_3.skillId);
                    this._next.setText(0, Language.getStringByParam(20242, _loc_3.skillLevel));
                    this._next.setText(1, SkillUtil.alySkillDesc(_loc_3));
                    this._next.setText(2, Language.getStringByParam(20799, _loc_5));
                    this._next.y = this._line1.y + 8;
                }
            }
            else
            {
                DisplayUtil.removeMe(this._cur);
                DisplayUtil.removeMe(this._txtMax);
                DisplayUtil.removeMe(this._line1);
                if (this._next.parent == null)
                {
                    contentContainer2D.addChild(this._next);
                }
                this._next.y = this._cur.y;
                this._next.setText(0, Language.getStringByParam(20242, this._skill.skillLevel));
                this._next.setText(1, SkillUtil.alySkillDesc(this._skill));
            }
            _scaleBg.setSize(this.width, this.height);
            return;
        }// end function

    }
}
